home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7442 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: due.unit.no!usenet
  2. From: Knut Magne Risvik <kmr@orakel.unit.no>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: [HLP] Easy Problem w/ Classes!
  5. Date: Fri, 23 Feb 1996 11:04:28 +0100
  6. Organization: The Norwegian University of Science and Technology
  7. Message-ID: <312D912C.102E7392@orakel.unit.no>
  8. References: <4gfn3v$jp@news.umbc.edu>
  9. NNTP-Posting-Host: apollo.orakel.unit.no
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.3.66 i586)
  14.  
  15. Sunil wrote:
  16. > Hello all
  17. >   Heres a little problem that I need help with.
  18. > // Point.h contains
  19. > Class Point {
  20. > private: int x;
  21. >          int y;
  22. > public: Point();
  23. > }
  24. > // LineSeg.h contains
  25. > class LineSeg{
  26. > private:
  27. >         Point end;
  28. >         Point start;
  29. > public:
  30. >         LineSeg();
  31. > }
  32. > // LineSeg.C contains
  33. > LineSeg::LineSeg()
  34. > {
  35. >  Point.end.x=0;  // Are these valid?
  36. >  Point.end.y=0;  // What do I need to add/del here?
  37. >  Point.start.x=0;
  38. >  Point.start.y=0;
  39. > }
  40.  
  41. The operations in LineSeg::LineSeg is not allowed because x and y in the
  42. Point class are private. Create a constructor for the Point class
  43. something like this :
  44.  
  45. Point::Point () {
  46.     x=y=0;
  47. }
  48.  
  49. And add functions in Point to set and get x and y coords
  50.